|
|
|
|
|
|
|
Now suppose you have a ray that passes through the point (px, py, pz) in the direction of the vector <Vx, Vy, Vz>. The parametric equations for this ray are: |
|
|
|
 |
|
|
|
|
X(t) = px + Vx * t
Y(t) = py + Vy * t
Z(t) = pz + Vy * t |
|
|
|
|
|
|
|
|
Suppose H is a point of intersection between the ray and the cylinder. The shortest distance from the cylinder's axis to the point H follows a vector R perpendicular to the axis as shown in Figure 17.18. The point I in Figure 17.18 marks the end of the vector R. |
|
|
|
|
|
|
|
|
Because the cylinder's axis is parallel to the vector W, the vectors W and R are perpendicular, so the dot product W R must be zero. |
|
|
|
 |
|
|
|
|
W R= Wx * Rx + Wy * Ry + Wz * Rz
= Wx * (Hx - Ix) + Wy * (Hy - Iy) + Wz * (Hz - Iz) |
|
|
|
|
|
|
|
|
The point H lies along the ray, so the parametric equations for the ray must generate the point H. In other words, for some value of t, Hx = px + Vx * t, Hy = py + Vy * t, and Hz = pz + Vz * t. |
|
|
|
|
|
|
|
|
Similarly, the point I lies along the cylinder's axis, so the parametric equations for the axis must generate the point I. For some value of u, Ix = x1 + Wx * u, and so forth. |
|
|
|
|
|
|
|
|
Substituting the parametric equations for the coordinates of the points H and I into the equation for the dot product gives: |
|
|
|
 |
|
|
|
|
W R= Wx * ((px + Vx * t) - (x1 + Wx * u)) +
Wy * ((py + Vy * t) - (y1 + Wy * u)) +
Wz * ((pz + Vz * t) - (z1 + Wz * u)) |
|
|
|
|
|
|
|
|
Figure 17.18
A ray intersecting a cylinder in two places. |
|
|
|
|
|